﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_DeliveryNoticeController : BaseApiController
    {
        #region DI

        public PB_DeliveryNoticeController(IPB_DeliveryNoticeBusiness pB_DeliveryNoticeBus)
        {
            _pB_DeliveryNoticeBus = pB_DeliveryNoticeBus;
        }

        IPB_DeliveryNoticeBusiness _pB_DeliveryNoticeBus { get; }

        #endregion

        #region 获取
        /// <summary>
        /// 发货单信息读取
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<RealNameDeliveryNoticeDTO>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_DeliveryNoticeBus.GetDataListAsync(input);
        }
        /// <summary>
        /// 回货单信息读取
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_DeliveryNotice>> GetDataReturnList(PageInput<ConditionDTO> input)
        {
            return await _pB_DeliveryNoticeBus.GetDataListReturnAsync(input);
        }

        [HttpPost]
        public async Task<PB_DeliveryNoticeDtoinfo> SelectProjectId(string ProjectId) {
       var AA=  _pB_DeliveryNoticeBus.SelectProjectId(ProjectId);
            return await AA;
        }
        [HttpPost]
        public async Task<PB_DeliveryNotice> GetTheData(IdInputDTO input)
        {
            return await _pB_DeliveryNoticeBus.GetTheDataAsync(input.id);
        }
        /// <summary>
        /// 备货详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        
        public async Task<PageResult<PB_DesignDetailItemDTO>> GetTheDataItem(PageInput<PB_DesignDetailselectDTO> input)
        {
            return await _pB_DeliveryNoticeBus.GetTheDataitemAsync(input);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task DeliveryNoticeSaveData(PB_DeliveryNoticeMasterSubDTO data)
        {
            if (data.main.Id.IsNullOrEmpty())
            {
                //InitEntity(data);
                //默认都是待审核
                data.main.AuditStatus = 0;
                await _pB_DeliveryNoticeBus.AddDataAsync(data);
            }
            else
            {
                await _pB_DeliveryNoticeBus.UpdateDataAsync(data);
            }
        }
        /// <summary>
        /// 提交审核
        /// </summary>
        /// <returns></returns>
        [HttpGet]

        public async Task<AjaxResult> SaveToExamine(string idIn,bool judge)
        {
            return await _pB_DeliveryNoticeBus.SaveToExamine(idIn, judge);


        }
        [HttpPost]
        public async Task<AjaxResult> SaveCloss(string idIn) {
            return await _pB_DeliveryNoticeBus.SaveCloss(idIn);
        }
        [HttpPost]
        public async Task<AjaxResult> GetallCount(string idIn)
        {
            return await _pB_DeliveryNoticeBus.GetallCount(idIn);
        }
        [HttpPost]
        public async Task<AjaxResult> CheckVerification() {
            return await _pB_DeliveryNoticeBus.CheckVerification();
        }
        /// <summary>
        /// 回货提交审核
        /// </summary>
        /// <returns></returns>
        [HttpGet]

        public async Task<AjaxResult> SaveReturnToExamine(string idIn, bool judge)
        {
            return await _pB_DeliveryNoticeBus.SaveReturnToExamine(idIn, judge);

        }
       
        [HttpPost]
        public async Task<AjaxResult> DeleteData(List<string> ids)
        {
           return await _pB_DeliveryNoticeBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 更具发货通知单明细查询发货详情
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<NoticeBuildingnumberDTO>> GetNoticeBuildingnumberList(PageInput<NoticeBuildingnumberConditionDTO> input)
        {
            return await _pB_DeliveryNoticeBus.GetNoticeBuildingnumberListAsync(input);
        }

        /// <summary>
        /// 更具发货通知单明细查询物料发货明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<NoticeBuildingnumberDTO>> GetNoticeBuildingnumberData(PageInput<NoticeBuildingnumberConditionDTO> input)
        {
            return await _pB_DeliveryNoticeBus.GetNoticeBuildingnumberDataAsync(input);
        }

        #endregion
    }
}